﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_TH_ContentMain : System.Web.UI.UserControl
{
    private DataSet objDataSet;
    protected void Page_Load(object sender, EventArgs e)
    {
        // Load the grid only the first time the page is loaded
        if (!Page.IsPostBack)
        {
            // Load the categories grid
            BindGrid();
        }
    }
    // Populate the GridView with data
    private void BindGrid()
    {
        QuangCaoBUS objQC = new QuangCaoBUS(TGDDConfiguration.DbConnectionString);
        try
        {
            objDataSet = objQC.SelectQuangCaoByViTri(4);
            repQuangCao4.DataSource = objDataSet.Tables[0];
            repQuangCao4.DataBind();
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    protected void LoginStatus_Admin_LoggedOut(object sender, EventArgs e)
    {
        if (Request.Cookies["UserId"] != null)
        {
            HttpCookie myCookie = new HttpCookie("UserId");
            myCookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(myCookie);
        }

        FormsAuthentication.SignOut();
        Roles.DeleteCookie();
        Session.Clear();
        Session.RemoveAll();
        Response.Redirect("Default.aspx");
    }
    protected void LoginStatus1_Customer_LoggedOut(object sender, EventArgs e)
    {
        if (Request.Cookies["UserId"] != null)
        {
            HttpCookie myCookie = new HttpCookie("UserId");
            myCookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(myCookie);
        }

        FormsAuthentication.SignOut();
        Roles.DeleteCookie();
        Session.Clear();
        Session.RemoveAll();
        Response.Redirect("Default.aspx");
    }
    protected void LoginStatus_Employee_LoggedOut(object sender, EventArgs e)
    {
        if (Request.Cookies["UserId"] != null)
        {
            HttpCookie myCookie = new HttpCookie("UserId");
            myCookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(myCookie);
        }

        FormsAuthentication.SignOut();
        Roles.DeleteCookie();
        Session.Clear();
        Session.RemoveAll();
        Response.Redirect("Default.aspx");
    }
}
